<template>
	<view class="celltransport">
		<!-- 头部 -->
		<view class="celltransport-header">
			<!-- 内容 -->
			<view class="celltransport-header-box">
				<view>
					<text class="iconfont celltransport-header-box-title" @tap="goHome">&#xe614;</text>
					<text>细胞运输</text>
				</view>
				<view>
					<text class="iconfont">&#xeb86;</text>
					<text class="iconfont">&#xe661;</text>
				</view>
			</view>
		</view>
		<!-- 地图 -->
		<view class="celltransport-map">
			<map :latitude="latitude" :longitude="longitude" :markers="markers">
				<!-- 按钮 -->
				<cover-image class="celltransport-btn" @tap="goRoute" src="../../static/image/celltransport/center.png" mode="scaleToFill"></cover-image>
				<!-- 我的位置 -->
				<cover-image class="celltransport-btn-me" @tap="goMePosition" src="../../static/image/celltransport/me.png" mode="scaleToFill"></cover-image>
			</map>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'map', //地图标题      
				latitude: 30.67, //纬度
				longitude: 104.07 ,//经度
				markers:[]
				//scale：5，//最小数，缩放范围最大，可见程度最大
				//scale：18，//最大数，缩放范围最小，可见程度最小
			}
		},
		methods: {
			/* 返回首页 */
			goHome: function() {
				console.log(1);
				uni.switchTab({
					url: '../index/index'
				})
			},
			/* 获取当前位置 */
			goMePosition: function(){
				const that = this;
				uni.getLocation({
				    type: 'wgs84',
				    success: function (res) {
						that.latitude= res.latitude;
						that.longitude= res.longitude;
						that.markers=[{id:'me',latitude:res.latitude,longitude: res.longitude,title:'我的位置',iconPath:"../../static/image/celltransport/mark.png" }]
				    },
				});
			},
			/* 跳转到路线输入页面 */
			goRoute:function(){
				uni.navigateTo({
					url:"./componets/route/route"
				})
			}
		},
		onReady() {
			const that = this;
			uni.getLocation({
			    type: 'wgs84',
			    success: function (res) {
					that.latitude= res.latitude;
					that.longitude= res.longitude;
					that.markers=[{id:'me',latitude:res.latitude,longitude: res.longitude,title:'我的位置',iconPath:"../../static/image/celltransport/mark.png" }]
			    },
			});
		}
	}
</script>

<style scoped lang="less">
	/* 引入color.less */
	@import url("../../static/color.less");

	/* 引入fontSize.less */
	@import url("../../static/fontSize.less");

	/* 主体 */
	.celltransport {
		height: 100vh;
		overflow: hidden;
		background-color: #F5F5F5;
	}

	/* 头部 */
	.celltransport-header {
		height: 150rpx;
		position: relative;
		top: 0;
		background-color: @masterColor;
		
		z-index: 900;

		/* 内容 */
		.celltransport-header-box {
			display: flex;
			width: 100%;
			height: 100rpx;
			position: absolute;
			bottom: 0;
			left: 0;
			color: @colorWrite;
			align-items: center;
			justify-content: space-between;

			view {
				&:first-child {
					width: 564rpx;
					font-size: @fontBigger;

					/* 标题 */
					.celltransport-header-box-title {
						padding-left: 34rpx;
						font-size: @fontBigger;
					}

					&>text:last-child {
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}

				&:last-child {
					width: 186rpx;
				}

				display: flex;
				align-items: center;
			}

			/* iconfont */
			.iconfont {
				margin: 0 25rpx 0 13rpx;
				font-weight: bold;
				font-size: 55rpx;
			}
		}
	}

	/* 地图 */
	.celltransport-map{
		height: calc(100vh - 150rpx);
		map{
			height: 100%;
			width: 100%;
		}
	}
	
	/* 按钮 */
	.celltransport-btn{
		display: flex;
		width: 205rpx;
		height: 105rpx;
		align-items: center;
		justify-content: center;
		color: @colorWrite;
		position: fixed;
		right: 273rpx;
		bottom: 50rpx;
		border: 1rpx solid #EBEAEA;
		border-radius: 50rpx;
		background: #4287FF;
		
		text.iconfont{
			margin-right: 25rpx;
		}
	}
	
	/* 我的位置 */
	.celltransport-btn-me{
		width: 90rpx;
		height: 90rpx;
		line-height: 90rpx;
		position: fixed;
		left: 15rpx;
		bottom: 50rpx;
		color: #4287FF;
		text-align: center;
		border: 1rpx solid #EBEAEA;
		border-radius: 50%;
		// background-color: @colorWrite;
		cover-image{
			width: 100%;
			height: 100%;
			position: absolute;
			top: 0;
			left: 0;
		}
	}
</style>
